<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\index\service;

use app\common\model\oms\RetrieveWamData as retrieveWamDataModel;
use app\common\model\oms\ServiceOrders as serviceOrdersModel;

/**
 * Description of DeviceService
 *
 * @author tommy.pan
 */
class ServiceService {

    public function saveDataToDb($params) {
        $params['create_time'] = time();
        $model = new retrieveWamDataModel();
        $create = $model->save($params);
        return $create;
    }

    /**
     * 通过serviceOrderId获取患者ID
     * @param type $serviceOrderId
     */
    public function getPatientId($serviceOrderId) {
        $serviceOrderModel = new serviceOrdersModel();
        $serviceOrderObj = $serviceOrderModel->get(['service_order_id' => $serviceOrderId]);
        if (true === empty($serviceOrderObj)) {
            return false;
        }
        $patientId = $serviceOrderObj->getData('patient_id');
        return $patientId;
    }

}
